
package ch.hearc.meteo.imp.afficheur.real.vue.atome;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

import ch.hearc.meteo.imp.afficheur.real.JFrameStationMeteo;
import ch.hearc.meteo.imp.afficheur.real.moo.StationMeteoElement;

public class JPanelStats extends JPanel
	{

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/
	public JPanelStats(String title, List<StationMeteoElement> stationMeteoElements, JPanelGraph panelGraph)
		{
		this.stationMeteoElements = stationMeteoElements;
		this.title = title;
		this.panelGraph = panelGraph;
		this.minColor = Color.WHITE;
		this.maxColor = Color.WHITE;
		geometry();
		control();
		apparence();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	public void refresh()
		{

		repaint();
		}

	/*------------------------------*\
	|*				Set				*|
	\*------------------------------*/
	public void setMin(String min)
		{
		this.labelMin.setText(TXT_MIN + min);
		this.labelMin.setForeground(minColor);
		}

	public void setMax(String max)
		{
		this.labelMax.setText(TXT_MAX + max);
		this.labelMax.setForeground(maxColor);
		}

	public void setMoy(String moy)
		{
		this.labelMoy.setText(TXT_MOY + moy);
		}

	/*------------------------------*\
	|*				Get				*|
	\*------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	private void geometry()
		{
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.labelMax = new JLabel(TXT_MAX + NO_VALUE);
		this.labelMin = new JLabel(TXT_MIN + NO_VALUE);
		this.labelMoy = new JLabel(TXT_MOY + NO_VALUE);

		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout(FlowLayout.CENTER));
		panel.add(this.labelMax);
		panel.add(this.labelMin);
		panel.add(this.labelMoy);

		this.add(panelGraph);
		this.add(panel);
		}

	private void control()
		{

		}

	private void apparence()
		{
		Font font = panelGraph.getFont();
		Border border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(JFrameStationMeteo.COLOR_S1, 1, true), this.title, TitledBorder.CENTER, TitledBorder.TOP, font, JFrameStationMeteo.COLOR_P2);
		this.setBorder(border);
		}

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/

	//Input
	protected List<StationMeteoElement> stationMeteoElements;
	private String title;
	private JPanelGraph panelGraph;
	//Tools
	private JLabel labelMin;
	private JLabel labelMax;
	private JLabel labelMoy;
	protected Color minColor;
	protected Color maxColor;

	public static final String TXT_MAX = "Max : ";
	public static final String TXT_MIN = "Min : ";
	public static final String TXT_MOY = "Moy : ";
	public static final String NO_VALUE = "----";
	}
